function png2avi(sPath)
	aviobj = avifile('out.avi');
	%dirS = dir([sPath, '/*bgestimate*.png']);
	%dirS = dir([sPath, '/*final*.png']);
	dirS = dir([sPath, '/*.png']);
	for i=1:length(dirS);
		sprintf('capturing frame %d of %d  %d percent left\n',i,length(dirS), round((length(dirS)-i)/length(dirS)*100))

		dirS(i).name
		img = imread([sPath, '/', dirS(i).name]);
		if(size(img,3)==3) 
			disp('3 channels found');
			frame = img;
		else
			disp('1 channel found, converting to 3 channels');
			imgRGB = zeros(size(img,1), size(img,2), 3);
			%img = img * 256;
			imgRGB(:,:,1) = img;
			imgRGB(:,:,2) = img;
			imgRGB(:,:,3) = img;
			frame = imgRGB;
		end

		aviobj = addframe(aviobj, frame);
	end
	aviobj = close(aviobj)
end
